package 排序算法;

import java.util.Arrays;

/**
 * @author kakayubei
 * @description
 * @date 2021/10/9 23:44
 */
public class BubbleSort {
    public static int[] bubbleSort(int[] array) {
        for (int i = 0, len = array.length ; i < len - 1; i++) {
            for (int j = i + 1; j < len; j++ ){
                if (array[j] < array[i]) {
                    int tmp = array[i];
                    array[i] = array[j];
                    array[j] = tmp;
                }
            }
        }
        return array;
    }

    public static void main(String[] args) {
        System.out.println(Arrays.toString(bubbleSort(new int[] { 2, 1, 5, 2, 9, 4 })));
    }
}
